﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;

namespace Rimz.Common
{
    public sealed class Utilities
    {
        /// <summary>
        /// Validate email address
        /// </summary>
        /// <param name="email">Email address to be validated</param>
        /// <returns></returns>
        public static bool isValidEmail(string email)
        {
            bool result = false;

            string strRegex = @"^([a-zA-Z0-9_\-\.]+)@((\[[0-9]{1,3}" +
                  @"\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([a-zA-Z0-9\-]+\" +
                  @".)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$";

            if (email == null)
                return result;
                        
            Regex re = new Regex(strRegex);

            result = re.IsMatch(email);

            return result;
        }

        /// <summary>
        /// Validate input text.
        /// </summary>
        /// <param name="text">text to be validated</param>
        /// <returns>Return true if string text contains only [a-zA-Z]</returns>
        public static bool isValidText(string text)
        {
            bool result = false;

            string strRegex = @"^[a-zA-Z]+";

            if (text == null)
                return result;

            Regex re = new Regex(strRegex);

            result = re.IsMatch(text);

            return result;
        }

        public static bool isValidPassword(string password)
        {

            bool result = false;

            string strRegex = @"^[a-zA-Z0-9]+";

            if (password == null)
                return result;

            Regex re = new Regex(strRegex);

            result = re.IsMatch(password);

            return result;
        }

    }
}
